/*

Author   : chaos

FileName : math_error.cpp

Date     : 16/08/17 19:07:09

*/
#include <iostream>
#include <string>

using namespace std;

class MathErrorExcp
{
    private:
        string err_msg;

    public:
        MathErrorExcp(const char * msg):err_msg(msg){}
        const string what(){ return err_msg; }

};
using namespace std;

int main(int argc ,char *argv[])
{

    int x,y ;

    try{
        cout << "Please input two integer for find modulus :" << endl;
        cin >> x >> y;

        if (y == 0)
            throw MathErrorExcp("Derive by Zero !\n");
        else if(!cin.good())
            throw string ("Not integer!");

        throw(1);
    }
    catch(MathErrorExcp e){cerr << e.what();}
    catch(string s){cerr << s << endl;}
    catch(...){cout << "modulus : " << x%y << endl;}

    cout << "After running try-throw-catch !" << endl;

    return 0;
}
